package com.lhj.xxsc.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author 罗惠江
 * @version 1.0
 * @email 1511619294@qq.com
 * @date 2021/1/4 15:26
 */

public class OrderConfirmVo {
	// 收货地址
	@Setter
	@Getter
	private List<MemberAddressVo> address;

	// 所有选中的购物项
	@Setter
	@Getter
	private List<OrderItemVo> items;

	// 发票。记录。。

	// 优惠信息
	@Setter
	@Getter
	private Integer integration;

	// 防重令牌
	@Setter
	@Getter
	String orderToken;

	// 库存map
	@Setter
	@Getter
	Map<Long, Boolean> stocks;

	public Integer getCount() {
		Integer i = 0;
		if (items != null) {
			for (OrderItemVo item : items) {
				i += item.getCount();
			}
		}
		return i;
	}
	// 订单总额
//	private BigDecimal total;

	public BigDecimal getTotal() {
		BigDecimal sum = new BigDecimal("0");
		if (items != null) {
			for (OrderItemVo item : items) {
				BigDecimal temp = item.getPrice().multiply(new BigDecimal(item.getCount()));
				sum = sum.add(temp);
			}
		}
		return sum;
	}

	// 应付金额
//	private BigDecimal payPrice;

	public BigDecimal getPayPrice() {
		BigDecimal payPrice = getTotal();
		return payPrice;
	}
}
